package com.surfilter.controller;

import java.util.Map;

import com.alibaba.fastjson.JSON;
import com.surfilter.bean.QueryResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.surfilter.bean.VirtualIdentity;
import com.surfilter.service.VirtualService;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class VirtualController {
	Logger logger = LoggerFactory.getLogger(this.getClass().getName());

	@Autowired
	private VirtualService virtualService;

	@RequestMapping("/virtual")
	public String toVirtual(){
		return "virtualIdentity";
	}

    @RequestMapping("/virtual/{info}/{type}")
    @ResponseBody
    public Object virtual(@PathVariable String info , @PathVariable String type) throws Exception{
    	//模拟传参
    	VirtualIdentity virtualIdentity = new VirtualIdentity();
    	virtualIdentity.setContent(info);
    	virtualIdentity.setVirtualtype(type);
    	Map<String, Object> correlationAnalysis = virtualService.correlationAnalysis(virtualIdentity);
    	System.out.println(correlationAnalysis);//查看结果
     return correlationAnalysis;
    }

    @RequestMapping("/virtual/getTableShow/{pageNum}")
    @ResponseBody
    public Object getTableShow(@PathVariable String pageNum){
		return virtualService.getTableShow(Integer.parseInt(pageNum));
    }


	@RequestMapping("/virtual/getDetailInfo/{account}/{virtualIdentity}/{virtualtype}")
	@ResponseBody
	public Object getDetailInfo(@PathVariable String account,@PathVariable String virtualIdentity,@PathVariable String virtualtype){

		return virtualService.getDetailInfo(account,virtualIdentity,virtualtype);
	}

	@RequestMapping("/virtual/queryResult/{account}")
	@ResponseBody
	public Object queryResult(@PathVariable String account,String page,String limit) throws Exception{
		QueryResult queryResult = new QueryResult();
		queryResult.setAccount(account);
		queryResult.setPageNum(Integer.parseInt(page));
		queryResult.setLimit(Integer.parseInt(limit));
		return virtualService.queryAccountResult(queryResult);
	}
}